package com.handsome.迭代器模式;

import java.util.Iterator;
import java.util.List;

/**
 * @author niechun
 * @date 2023/3/19 13:41
 */
public class ComputerCollege implements College{
    private Department[] departments;
    //数组中元素的个数
    private int quality=0;

    public ComputerCollege() {
        departments=new Department[5];
        add(new Department("JAVA",""));
        add(new Department("PHP",""));
        add(new Department("GO",""));

    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void add(Department department) {
        departments[quality]=department;
        quality+=1;

    }

    @Override
    public Iterator getIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
